import 'dart:convert';
import 'package:flutter/services.dart' show rootBundle;
import '../model/common_model.dart';


///加载asset 里的json 文件 返回 Model
class ConfigUtil {
  ///
  static Future<CommonModel> loadCommon() async {
    String path = "assets/config/common.json";
    String json = await rootBundle.loadString(path);

    Map<String, dynamic> jsonMap = jsonDecode(json);
    CommonModel commonModel = CommonModel.fromJson(jsonMap);
    return commonModel;
  }


  static Future<Map<String, dynamic>> loadErrorMsg() async {
    String path = "assets/config/error_code_msg.json";
    String json = await rootBundle.loadString(path);
    Map<String, dynamic> jsonMap = jsonDecode(json);
    return jsonMap;
  }
}
